# coding=utf8

from app import create_app
from app.modules.common.jsonFileUtil import getJsonFile
from app.extensions import db
from app.modules.zones.models import ZoneInfo
from app.modules.common.utils import DbCommit

application = create_app(flask_config = 'local')


def main(_json):
    with application.app_context():
        # _json = getJsonFile(_file)
        for _zone in _json:
            db.session.add(
                ZoneInfo(env_name = 'online', zone_code = _zone['zone_code'], zone_alias = _zone['zone_alias'],
                         zone_title = _zone['zone_title'], parent_code = _zone['parent_code'],
                         current_status = 'GNONE', operate_group = 'NONE'))
        DbCommit()


if __name__ == '__main__':
    _zones = [
        {
            "instructions": "占用32G内存 50G硬盘空间",
            "zone_alias": "gzidc",
            "zone_code": "uc.gzidc.area",
            "zone_title": "中国区",
            "parent_code": None
        },
        {
            "instructions": "",
            "zone_alias": "szx",
            "zone_code": "uc.gzidc.warehouse.szx",
            "zone_title": "深圳仓",
            "parent_code": "uc.gzidc.area"
        },
        {
            "instructions": "",
            "zone_alias": "usaws",
            "zone_code": "uc.usaws.area",
            "zone_title": "美国区",
            "parent_code": None
        },
        {
            "instructions": "",
            "zone_alias": "usla",
            "zone_code": "uc.usaws.warehouse.usla",
            "zone_title": "美西仓",
            "parent_code": "uc.usaws.area"
        },
        {
            "instructions": "",
            "zone_alias": "usky",
            "zone_code": "uc.usaws.warehouse.usky",
            "zone_title": "美东仓",
            "parent_code": "uc.usaws.area"
        },
        {
            "instructions": "",
            "zone_alias": "ustx",
            "zone_code": "uc.usaws.warehouse.ustx",
            "zone_title": "美三仓",
            "parent_code": "uc.usaws.area"
        },
        {
            "instructions": "",
            "zone_alias": "euaws",
            "zone_code": "uc.euaws.area",
            "zone_title": "欧洲区",
            "parent_code": None
        },
        {
            "instructions": "",
            "zone_alias": "ukls",
            "zone_code": "uc.euaws.warehouse.ukls",
            "zone_title": "英一存储仓",
            "parent_code": "uc.euaws.area"
        },
        {
            "instructions": "",
            "zone_alias": "ukle",
            "zone_code": "uc.euaws.warehouse.ukle",
            "zone_title": "英国一仓",
            "parent_code": "uc.euaws.area"
        },
        {
            "instructions": "",
            "zone_alias": "ukma",
            "zone_code": "uc.euaws.warehouse.ukma",
            "zone_title": "英国二仓",
            "parent_code": "uc.euaws.area"
        },
        {
            "instructions": "",
            "zone_alias": "debre",
            "zone_code": "uc.euaws.warehouse.debre",
            "zone_title": "德国仓",
            "parent_code": "uc.euaws.area"
        },
        {
            "instructions": "",
            "zone_alias": "bemo",
            "zone_code": "uc.euaws.warehouse.bemo",
            "zone_title": "比利时仓",
            "parent_code": "uc.euaws.area"
        },
        {
            "instructions": "",
            "zone_alias": "ukgf",
            "zone_code": "uc.euaws.warehouse.ukgf",
            "zone_title": "英国三仓",
            "parent_code": "uc.euaws.area"
        },
        {
            "instructions": "",
            "zone_alias": "auaws",
            "zone_code": "uc.auaws.area",
            "zone_title": "澳洲区",
            "parent_code": None
        },
        {
            "instructions": "",
            "zone_alias": "ausyd",
            "zone_code": "uc.auaws.warehouse.ausyd",
            "zone_title": "澳洲仓",
            "parent_code": "uc.auaws.area"
        },
        {
            "instructions": "",
            "zone_alias": "can",
            "zone_code": "uc.gzidc.warehouse.can",
            "zone_title": "广州仓",
            "parent_code": "uc.gzidc.area"
        },
        {
            "instructions": "",
            "zone_alias": "sha",
            "zone_code": "uc.gzidc.warehouse.sha",
            "zone_title": "上海仓",
            "parent_code": "uc.gzidc.area"
        },
        {
            "instructions": "",
            "zone_alias": "tao",
            "zone_code": "uc.gzidc.warehouse.tao",
            "zone_title": "青岛仓",
            "parent_code": "uc.gzidc.area"
        },
        {
            "instructions": "",
            "zone_alias": "ngb",
            "zone_code": "uc.gzidc.warehouse.ngb",
            "zone_title": "宁波仓",
            "parent_code": "uc.gzidc.area"
        },
        {
            "instructions": "",
            "zone_alias": "hkg",
            "zone_code": "uc.gzidc.warehouse.hkg",
            "zone_title": "香港仓",
            "parent_code": "uc.gzidc.area"
        },
        {
            "instructions": "",
            "zone_alias": "auss",
            "zone_code": "uc.auaws.warehouse.auss",
            "zone_title": "澳洲存储仓",
            "parent_code": "uc.auaws.area"
        }
    ]
    main(_zones)
    pass
